package org.example11;

import java.util.Collection;

public interface CheckSum {

    long checksum();

    default long checksum(final long v1, final long v2){
        return v1 ^ v2;
    }

    default long checksum(final Collection<? extends CheckSum> factors, long v) {
        if (factors != null && !factors.isEmpty()) {
            for (final CheckSum factor : factors) {
                v = checksum(v, factor.checksum());
            }
        }
        return v;
    }
}
